<div class="modal-dialog">
    <div class="modal-content">
        <form role="form" action="{:U('purview/add')}" method="post" id="addForm">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title">添加模块</h4>
            </div>
            <div class="modal-body">

                <div class="form-group">
                    <label for="name">模块名称</label>
                    <input type="name" class="form-control" id="name" name="name">
                </div>
                <div class="form-group">
                    <label for="pid">上级模块</label>
                   <select name="pid" id="pid" class="form-control">
                   		<option value="0">一级模块</option>
                   		<volist name="parents" id="val">
                   			<option value="{$key}" <eq name="key" value="$pid">selected</eq>>{$val}</option>	
                   		</volist>
                   	
                   </select>
                </div>
                
                <div class="form-group">
                    <label for="menus">关联菜单</label>
                   <select name="menus[]" id="menus" multiple="multiple" style="width: 100%;">
                   		{$treeMenu}
                   </select>
                </div>
                

            </div>
            <div class="modal-footer">
                <button  type="submit" class="btn btn-danger">保存</button>
            </div>
        </form>
    </div>
    <script type="text/javascript">
    $("#addForm").bootstrapValidator({              
                    excluded: [':disabled'],
                    feedbackIcons: {
                        valid: 'glyphicon glyphicon-ok',
                        invalid: 'glyphicon glyphicon-remove',
                        validating: 'glyphicon glyphicon-refresh'
                    },
                    submitHandler: function (validator, form, submitButton) {
                        validator.defaultSubmit();
                    },
                    fields: {
                        name: {
                            validators: {
                                notEmpty: {
                                    message: '模块名称不能为空'
                                }
                            }
                        }
                    }
                });
    
    	$("#menus").select2({
			placeholder: "关联菜单",
			allowClear: true,
		});
    </script>